<%-- 
    Document   : template
    Created on : 2016-3-10, 17:22:23
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link href="${base}/css/bootstrap-paper.css" rel="stylesheet">
        <link href="${base}/css/font-awesome.css" rel="stylesheet">

        <script type="text/javascript" src="${base}/js/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="${base}/js/angular/angular.min.js"></script>
        <script type="text/javascript" src="${base}/js/jquery.cxhd.js"></script>
        <script src="${base}/js/angular/ui-bootstrap-tpls-0.12.0.min.js"></script>
    </head>
    <body>

        <div class="container">
            <div class="panel panel-danger">
                <div class="panel-heading">
                    <span style="float: left">模板管理</span>
                    <div>
                        <input ng-model="searchContent" placeholder="名字/病人ID" style="width:320px; float: left;margin-left: 20px" class="form-control input-sm" />
                        <button ng-click="getList()" style="float: left" class="btn btn-success btn-sm"><span class="fa fa-search"></span>&nbsp;&nbsp;搜索</button>


                    </div>
                </div>
                <table class="table">
                    <tr>
                        <th>序号</th>
                        <th>住院号</th>
                        <th>名字</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>主治医生</th>
                        <th>入院时间</th>
                        <th>备注</th>
                    </tr>
                    <tr ng-repeat="list in lists">
                        <td>{{$index}}</td>
                        <td>{{list.code}}</td>
                        <td>{{list.name}}</td>
                        <td>{{list.sex}}</td>
                        <td>{{list.age}}</td>
                        <td>{{list.doctor}}</td>
                        <td>{{list.in_time}}</td>
                        <td>{{list.note}}</td>
                    </tr>
                </table>
            </div>
        </div>
        <div style="width: 100%;text-align: center">
            <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

        </div>
    </body>
</html>
<script type="text/javascript">
    angular.module("template", ['ui.bootstrap'])
        .controller("mainController", function($scope) {

            var so = $scope;
            $scope.data = {currentPage: 1};
            so.setPage = function(pageNo) {
                $scope.data.currentPage = pageNo;
            };

            so.pageChanged = function() {
                so.getList();
            };

            so.data.maxSize = 10;
            so.data.bigTotalItems = 20;
            so.data.bigCurrentPage = 1;
            so.data.pageSize = 10;

            so.getList = function() {
                $.post("getPatientList",{content:so.searchContent,pageSize: so.data.pageSize, currentPage: so.data.currentPage}, function(data) {
                   
                    if(data){
                    so.lists = data.list;
                    so.data.bigTotalItems = data.totalRow;
                    if (so.lists) {
                        for ( var i in so.lists) {
                            if (so.lists[i].pat_sex == 'F') {
                                so.lists[i].pat_sex = "男";
                            } else {
                                so.lists[i].pat_sex = "女";
                            }
                        }
                    }
                    so.$apply();
                }
                });
            }
           
            so.getList();

        })

</script>
